package com.tuyue.police.controller.vip;

import com.tuyue.police.bean.MessageBean;
import com.tuyue.police.biz.IPoliceInfoBiz;
import com.tuyue.police.pojo.PoliceInfo;
import com.tuyue.police.util.Result;
import com.tuyue.police.util.ResultUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort;
import org.springframework.data.web.PageableDefault;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @Author: 王金海
 * @Description:
 * @Date: Created by Administrator on 2018/3/16.
 * @Modified By:
 */
@RestController
@RequestMapping("vip/policeInfo")
public class PoliceInfoController {

    @Autowired
    private IPoliceInfoBiz policeInfoBiz;


    @PostMapping("add")
    public Result add(@RequestBody PoliceInfo policeInfo){
        PoliceInfo info = policeInfoBiz.add(policeInfo);
        return ResultUtil.success(info);
    }
    @GetMapping("pagelist/{userId}")
    public Result pagelist(@PageableDefault(size = 10, sort = {"pInfoTime"}, direction = Sort.Direction.DESC)
                                       Pageable pageable, @PathVariable Long userId){
        Page<PoliceInfo> policeInfos = policeInfoBiz.pageList(pageable, userId);
        return ResultUtil.success(policeInfos);
    }
    @GetMapping("findGroupTime/{userId}")
    public Result findGroupTime(@PathVariable Long userId){
        List<MessageBean> groupTime = policeInfoBiz.findGroupTime(userId);
        return ResultUtil.success(groupTime);
    }


}
